package com.itcast.web.action.product;



import javax.annotation.Resource;


import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.junit.Test;
import org.springframework.stereotype.Controller;

import com.itcast.bean.PageIndex;
import com.itcast.bean.QueryResult;
import com.itcast.bean.product.ProductType;
import com.itcast.service.product.ProductTypeService;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ProductTypeAction")  
@Namespace("/")  
@ParentPackage("struts-default") 
public class ProductTypeAction  extends ActionSupport{
	public int maxresult;
	public int firstindex;
	public ProductType productType;
	private String uname;
	private String pwd;
	
	
	@Resource(name ="productTypeServiceBean") 
	private ProductTypeService productTypeService;
	


////服务器端验证
//	public void validate() {
//		if(uname==null||uname.length()<1){
//			this.addFieldError("unameError", "用户名不能为空");
//		}
//		if(pwd ==null||pwd.length()<1){
//			this.addFieldError("pwdError", "密码不能为空");
//		}
////	先执行服务器端的验证： 如果通过的话，
////		才执行execute业务方法	
////	如果	validate() 没有通过的话，就默认执行input页面
//	}
	@Override
	@Action(value="/hahahaha,mytestsuccecs",
				results={
					@Result(name="success",location="/WEB-INF/page/controlcenter/default.jsp"),
					@Result(name="input",location="/index.jsp")
				}
			)
	public String execute() {
		  productType =productTypeService.find(ProductType.class, 2);
		 return SUCCESS;
	}

	public ProductType getProductType() {
		return productType;
	}

	public void setProductType(ProductType productType) {
		this.productType = productType;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	
	

}
